package com.tianzeculture.stagebao.activity.personal;

import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.tianzeculture.stagebao.R;
import com.tianzeculture.stagebao.activity.artist.AddTalentDataActivity;
import com.tianzeculture.stagebao.activity.artist.ArtistEditPriceActivity;
import com.tianzeculture.stagebao.activity.personal.adapter.JobAdapter;
import com.tianzeculture.stagebao.activity.personal.adapter.JobTwoAdapter;
import com.tianzeculture.stagebao.activity.personal.adapter.WorkAdapter;
import com.tianzeculture.stagebao.base.BaseActivity;
import com.tianzeculture.stagebao.bean.AllIndustryBean;
import com.tianzeculture.stagebao.bean.JobBean;
import com.tianzeculture.stagebao.bean.PersonnelPoolBean;
import com.tianzeculture.stagebao.network.enity.MSG;
import com.tianzeculture.stagebao.util.StatusBarUtil;
import com.tianzeculture.stagebao.util.Util;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2018/6/19 0019.
 * 职业分类
 */

public class SelectJobTwoActivity extends BaseActivity {
    @BindView(R.id.tvTitle)
    TextView tvTitle;
    @BindView(R.id.lvJob)
    ListView lvJob;
    //    JobTwoAdapter jobTwoAdapter;
//    String job1 = "";
    AllIndustryBean job1;
    WorkAdapter workAdapter = null;
    boolean isEdit;
    boolean isAdd;

    @Override
    public void initUI() {
        super.initUI();
        StatusBarUtil.setWindowStatusBarColor(this, R.color.colorGray_F8);
        job1 = (AllIndustryBean) getIntent().getSerializableExtra("Job1");
        isEdit = getIntent().getBooleanExtra("isEdit", false);
        isAdd = getIntent().getBooleanExtra("isAdd", false);
        tvTitle.setText(job1.getTag() + "分类");

//        final List<String> jobs = new ArrayList<>();
//        jobs.add("摇滚型歌手");
//        jobs.add("创作型歌手");
//        jobs.add("hip hop型歌手");
//        jobs.add("情歌型歌手");
//        jobs.add("其他");
        if (job1 == null)
            finish();

        workAdapter = new WorkAdapter(this, job1.getList());
        lvJob.setAdapter(workAdapter);


//        jobTwoAdapter = new JobTwoAdapter(this, jobs);
//        lvJob.setAdapter(jobTwoAdapter);

        lvJob.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent = getIntent();
                intent.putExtra("JOB", job1.getList().get(i));
                if (isEdit) {
                    startActivity(new Intent(SelectJobTwoActivity.this, ArtistEditPriceActivity.class).putExtra("job", job1.getList().get(i)).putExtra("isEdit", isEdit));
                }
                if (isAdd) {
                    startActivity(new Intent(SelectJobTwoActivity.this, ArtistEditPriceActivity.class).putExtra("job", job1.getList().get(i)).putExtra("isAdd", isAdd));
                }
                setResult(Util.CHOOSE_JOB, intent);
                finish();
            }
        });
    }


    @Override
    public void refreshUI(int taskId, MSG msg) {
        super.refreshUI(taskId, msg);
    }

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_select_job;
    }
}
